//
//  WelcomeViewController.swift
//  StickyCollectionView
//
//  Created by Bogdan Matveev on 02/02/16.
//  Copyright © 2016 Bogdan Matveev. All rights reserved.
//

import UIKit

class WelcomeViewController: UIViewController {

    var backgroundImageView: UIImageView!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        let blurEffect = UIBlurEffect(style: .Light)
        let visualEffectView = UIVisualEffectView(effect: blurEffect)
        
        backgroundImageView = UIImageView()
        backgroundImageView.frame = CGRectMake(0, 0, ScreenWidth, ScreenHeight)
        backgroundImageView.image = UIImage(named: "rain")
        self.view.addSubview(backgroundImageView)
        
        visualEffectView.frame = backgroundImageView.bounds
        backgroundImageView.addSubview(visualEffectView)
        
        
        let btn1 = UIButton()
        btn1.tag = 1
        btn1.frame = CGRectMake(100, 100, ScreenWidth-200, 60)
        btn1.setTitle("cornerCollection", forState: UIControlState.Normal)
        btn1.titleLabel?.backgroundColor = UIColor.grayColor()
        btn1.addTarget(self, action: #selector(WelcomeViewController.pushToCollection(_:)), forControlEvents: UIControlEvents.TouchUpInside)
        
        let btn2 = UIButton()
        btn2.frame = CGRectMake(100, 150, ScreenWidth-200, 60)
        btn2.setTitle("primerCollection", forState: UIControlState.Normal)
        btn2.titleLabel?.backgroundColor = UIColor.grayColor()
        btn2.addTarget(self, action: #selector(WelcomeViewController.pushToCollection(_:)), forControlEvents: UIControlEvents.TouchUpInside)
        btn2.tag = 2
        
        self.view.addSubview(btn1)
        self.view.addSubview(btn2)
    }
    
    func pushToCollection(sender:UIButton) -> Void {
       
        let cornerVC = CornerViewController()
        let primerVC = PrimerViewController()
        
        if sender.tag == 1 {
           self.navigationController?.pushViewController(cornerVC, animated: true)
        }else{
           self.navigationController?.pushViewController(primerVC, animated: true)
        }
    }

}
